package com.blog.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.blog.domain.DTO.AddArticleDto;
import com.blog.domain.DTO.ArticleListDto;
import com.blog.domain.ResponseResult;
import com.blog.domain.entity.Menu;
import com.blog.domain.vo.ArticleVo;
import com.blog.service.ArticleService;
import com.blog.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/content/article")
public class ArticleController {

	@Autowired
	private ArticleService articleService;

	@Autowired
	private MenuService menuService;


	/**新增博文
	 *
	 * @param addArticleDto
	 * @return
	 */
	@PostMapping
	public ResponseResult addArticle(@RequestBody AddArticleDto addArticleDto){

		return articleService.addArticle(addArticleDto);

	}

	/**文章分页查询
	 *
	 * @param pageNum
	 * @param pageSize
	 * @param articleListDto
	 * @return
	 */

	@GetMapping("/list")
	public ResponseResult listArticle(Integer pageNum, Integer pageSize, ArticleListDto articleListDto){

		return articleService.listArticle(pageNum,pageSize,articleListDto);
	}


	/**按文章id查询文章详情
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/{id}")
	public ResponseResult<ArticleVo> selectArticleDatail(@PathVariable  Long id){

		return articleService.selectArticleDatail(id);
	}

	/**更新文章
	 *
	 * @param articleVo
	 * @return
	 */
	@PutMapping
	public ResponseResult updateArticle(@RequestBody ArticleVo articleVo){

		return articleService.updateArticle(articleVo);
	}

	/**删除博客
	 *
	 * @param ids
	 * @return
	 */
	@DeleteMapping("/{id}")
	public ResponseResult deleteArticle(@PathVariable("id") List<Long> ids){

		return articleService.deleteArticle(ids);
	}


}
